package com.array.generate;

import com.generic.genericinterface.demo1.Generator;

/**
 * 非静态内部类
 * 
 * @author Administrator
 *
 */
public class CountingGenerator2 {

	public class Boolean implements Generator<java.lang.Boolean> {

		public java.lang.Boolean value = false;

		@Override
		public java.lang.Boolean next() {
			value = !value;
			return value;
		}

	}

	public class Byte implements Generator<java.lang.Byte> {

		private byte value = 0;

		@Override
		public java.lang.Byte next() {
			return value++;
		}

	}

	static char[] chars = ("abcdefghifklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
			.toCharArray();

	public class Character implements Generator<java.lang.Character> {

		int index = -1;

		@Override
		public java.lang.Character next() {
			index = (index + 1) % chars.length;
			return chars[index];
		}

	}

	public class String implements Generator<java.lang.String> {

		private int length = 7;

		Generator<java.lang.Character> cg = new Character();

		public String() {

		}

		public String(int lenght) {
			this.length = lenght;
		}

		@Override
		public java.lang.String next() {
			char[] buf = new char[length];
			for (int i = 0; i < length; i++) {
				buf[i] = cg.next();
			}
			return new java.lang.String(buf);
		}

	}

}
